package com.ruoyi.ax.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ax.domain.AxAccountChangeRecord;
import com.ruoyi.ax.service.IAxAccountChangeRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 积分变细Controller
 * 
 * @author ruoyi
 * @date 2025-05-07
 */
@RestController
@RequestMapping("/ax/axAccountChangeRecord")
public class AxAccountChangeRecordController extends BaseController
{
    @Autowired
    private IAxAccountChangeRecordService axAccountChangeRecordService;

    /**
     * 查询积分变细列表
     */
    @GetMapping("/list")
    public TableDataInfo list(AxAccountChangeRecord axAccountChangeRecord)
    {
        startPage();
        List<AxAccountChangeRecord> list = axAccountChangeRecordService.selectAxAccountChangeRecordList(axAccountChangeRecord);
        return getDataTable(list);
    }

    @GetMapping("/mylist")
    @Log(title = "我的积分变细", businessType = BusinessType.EXPORT)
    public TableDataInfo mylist(AxAccountChangeRecord axAccountChangeRecord)
    {
        startPage();
        axAccountChangeRecord.setSysuserId(SecurityUtils.getUserId());
        List<AxAccountChangeRecord> list = axAccountChangeRecordService.selectAxAccountChangeRecordList(axAccountChangeRecord);
        return getDataTable(list);
    }

    /**
     * 导出积分变细列表
     */
    @Log(title = "积分变细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AxAccountChangeRecord axAccountChangeRecord)
    {
        List<AxAccountChangeRecord> list = axAccountChangeRecordService.selectAxAccountChangeRecordList(axAccountChangeRecord);
        ExcelUtil<AxAccountChangeRecord> util = new ExcelUtil<AxAccountChangeRecord>(AxAccountChangeRecord.class);
        util.exportExcel(response, list, "积分变细数据");
    }

    /**
     * 获取积分变细详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(axAccountChangeRecordService.selectAxAccountChangeRecordById(id));
    }

    /**
     * 新增积分变细
     */
    @Log(title = "积分变细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AxAccountChangeRecord axAccountChangeRecord)
    {
        return toAjax(axAccountChangeRecordService.insertAxAccountChangeRecord(axAccountChangeRecord));
    }

    /**
     * 修改积分变细
     */
    @Log(title = "积分变细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AxAccountChangeRecord axAccountChangeRecord)
    {
        return toAjax(axAccountChangeRecordService.updateAxAccountChangeRecord(axAccountChangeRecord));
    }

    /**
     * 删除积分变细
     */
    @Log(title = "积分变细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(axAccountChangeRecordService.deleteAxAccountChangeRecordByIds(ids));
    }
}
